function saveEvent() {
    // var form = $('#eventForm').serialize();
    var form = {'assignee': $('#assignee').val(), 'day': $('#day').val(), 'content': $('#content').val()};
    $.ajax({
        url: "/save-event",
        type: "POST",
        data: JSON.stringify(form),
        contentType: 'application/json;charset=utf-8',//设置数据类型JSON
        success: function (result) {
            alert(result);
            window.location.href = "/";
        }
    })
}

function saveUser() {
    // var form = $('#eventForm').serialize();
    var form = {'name': $('#name').val()};
    $.ajax({
        url: "/save-user",
        type: "POST",
        data: JSON.stringify(form),
        contentType: 'application/json;charset=utf-8',//设置数据类型JSON
        success: function (result) {
            alert(result);
            window.location.href = "/";
        }
    })
}

function back() {
    window.location.href = "/";
}

function toSaveEventPage() {
    window.location = '/event-save-page';
}

function toSaveUserPage() {
    window.location = '/user-save-page';
}

function deleteUser(data) {
    $.ajax({
        url: "/delete-user",
        type: "DELETE",
        data: {"id": data.value},
        success: function (result) {
            alert(result);
            window.location = "/";
        }
    })
}

// 格式化限制数字文本框输入，只能数字或者两位小数
function format_input_num(obj){
    // // 清除"数字"和"."以外的字符
    // obj.value = obj.value.replace(/[^\d.]/g,"");
    // // 验证第一个字符是数字
    // obj.value = obj.value.replace(/^\./g,"");
    // // 只保留第一个, 清除多余的
    // obj.value = obj.value.replace(/\.{2,}/g,".");
    // obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
    // 只能输入两个小数
    obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');
}